
<%@page import="ll.sms.web.*"%><%@ page language="java" import="java.util.*,ll.sms.pojo.*,org.json.simple.*" pageEncoding="UTF-8"%>
<%@page import="ll.sms.util.*,org.apache.commons.lang.*"%>

<%

String currentUserId = SmsUtil.sessionHelper(session,AdminProperty.aid);
String sort = ParamUtils.getParameter(request,"sort");
int index = ParamUtils.getIntParameter(request,"start",0);
int pageSize = ParamUtils.getIntParameter(request,"limit",15);
int currentPage = 1+(index/pageSize);
int total = WebBusinessImpl.getInstance().countTable("sms_admin",null);

String dir = request.getParameter("dir");
if(dir == null){
	dir = "ASC";
}
System.out.println();
String orderStr = null;
if(sort != null && !sort.equals("")){
	orderStr = " "+sort+" "+dir+" ";
}

//属于该业务员所有用户
if(!StringUtils.isBlank( request.getParameter("adminbelong") )){
String s = ExtJsonBuilder.toExtJsonString(total,  WebBusinessImpl.getInstance().pageQuery(SmsAdmin.class,"sms_admin","where acompany='"+currentUserId+"' and arank = "+SmsConstant.OPERATOR_TYPE,currentPage,pageSize,orderStr));
response.getWriter().print(s);
return;
}


//属于通道
if(!StringUtils.isBlank( request.getParameter("channel") )){
		 List<ChannelCombox> list = new ArrayList<ChannelCombox>();
		//该处需要注册的类名必须是在channelxml文件里配置好的类名
		 List<Channel> channelList = Channel.getAllChannel();
			System.out.print(channelList.size());
			for (Channel channel : channelList) {
				 ChannelCombox ccbox = new ChannelCombox();
		    	 ccbox.setClazzname(channel.getImplClassName()+"#"+channel.getDefaultChannelName());
		    	 ccbox.setShowname(channel.getDefaultChannelName());
				 list.add(ccbox);
			}


//FIXME :de
response.getWriter().print(ExtJsonBuilder.toExtJsonString(list.size(),list));
return;
}


if("manage".equals(request.getParameter("manage"))){
List<ChannelCombox> list = SmsUtil.getChannelList();
response.getWriter().print(ExtJsonBuilder.toExtJsonString(list.size(),list));
return;
}


String s = ExtJsonBuilder.toExtJsonString(total,  WebBusinessImpl.getInstance().pageQuery(SmsAdmin.class,"sms_admin",null,currentPage,pageSize,orderStr));
response.getWriter().print(s);
%>
